home *** CD-ROM | disk | FTP | other *** search
/ Power Programmierung 2 / Power-Programmierung CD 2 (Tewi)(1994).iso / c / library / mslang / zstud1 / zip.ba_ / ZIP.BAS
Encoding:
BASIC Source File  |  1994-04-09  |  9.4 KB  |  181 lines

  1. '////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  2. '// 
  3. '//        Zip Studio 1.2 COPYRIGHT 1993, 1994 Denis CHEVRON 
  4. '//
  5. '////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  6. '//
  7. '//        Zip functions declarations header file for Basic and Basic like languages
  8. '//        To Zip, Put ZDLL12A.DLL and ZDLL12B.DLL in the current dir and add
  9. '//        declarations below into your GLOBAL.BAS file.
  10. '//        To UnZip, Put UZDLL12.DLL in the current dir.                               
  11. '//
  12. '////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  13. '//
  14. '//        To get more informations, have a look at ZIP.H.
  15. '//
  16. '////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  17.  
  18. '////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  19. '//
  20. '//        Zip functions
  21. '//
  22. '////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  23.  
  24. '/* Errors constants */
  25. Global Const ZERROR_OK        =0    ' No error
  26. Global Const ZERROR_WARNING    =1    ' Just a warning (not an error)
  27. Global Const ZERROR_DESTFILE    =2    ' Destfile ( *.ZIP ) error
  28. Global Const ZERROR_INTERNAL     =3    ' Internal error
  29. Global Const ZERROR_FORMAT    =4    ' Not a Zip file
  30. Global Const ZERROR_NOMEM    =5    ' Not enough memory 
  31. Global Const ZERROR_NOFILE    =6    ' Nothing to do ( can be just a warning )
  32. Global Const ZERROR_NODLL    =7    ' Can' t find required DLLs
  33. Global Const ZERROR_COMMENT    =8    ' Comment missing or NULL
  34.  
  35.  
  36. '/* Overwrite mode */
  37. Global Const OVERWRITE_ALWAYS    =0    ' Always overwrite ( always zip files ) (default)
  38. Global Const OVERWRITE_NEVER    =1     ' Never overwrite
  39. Global Const OVERWRITE_PROMPT    =2    ' Ask the user
  40. Global Const OVERWRITE_UPDATE    =3    ' Overwrite if external file is newer
  41.  
  42.  
  43. '/* Language mode ( for the replace dialog box )*/
  44. Global Const LANGUAGE_FRENCH    =0    ' French mode
  45. Global Const LANGUAGE_ENGLISH    =1    ' US Mode ( default )
  46.  
  47.  
  48. '/* More easy to use with AddFileToZip */
  49. Global Const STOREPATH_NO    =0    ' Don' t store paths
  50. Global Const STOREPATH_YES    =1    ' Store paths
  51. Global Const RECURSE_NO        =0    ' Don' t recurse sub dirs
  52. Global Const RECURSE_YES    =1    ' Recurse sub dirs
  53.  
  54.  
  55. '/* Notification messages */
  56. 'Global Const ZN_ZIPPING    =WM_USER + 46    ' Zipping a file, WP = compressed size in K, LP = current file name
  57. 'Global Const ZN_FILEZIPPED    =WM_USER + 45    ' File is zipped, WP = compress rate, LP = file name
  58. 'Global Const ZN_WRITING    =WM_USER + 48    ' Replace the Zip file, LP = zip file name
  59. 'Global Const ZN_DELETING    =WM_USER + 47    ' Delete a file , LP = current file name
  60. 'Global Const ZN_REPARING    =WM_USER + 49    ' Repare a Zip file, WP = (int)state
  61.                         ' step =  1 : Read / Write ,  LP = current file name
  62.                         ' step = 3 : Checking zip file, LP = zip file name
  63. 'Global Const ZN_COMPUTE    =WM_USER +52    ' Before zip read, WP = zip files ( over 500, computing can be very long )
  64.  
  65.  
  66. '/* Main functions */
  67. Declare Sub      ZipInit     Lib "ZDLL12A.dll"( ByVal szYourName$, ByVal szPassword$ )              'Init the Zip DLL
  68. Declare Function AddFileToZip     Lib "ZDLL12A.dll"( ByVal szZipFile$, ByVal szMask$, 
  69.                            ByVal OverwriteMode%, ByVal bStorePath%, 
  70.                            ByVal bRecurse%, ByVal hParentWnd% ) As Integer    'Zip a file
  71. Declare Function ZipDeleteFiles Lib "ZDLL12A.dll"( ByVal szZipFile$, ByVal szFiles$, 
  72.                            ByVal hParentWnd% ) As Integer            'Delete files in a Zip
  73. Declare Function ZipRepare     Lib "ZDLL12A.dll"( ByVal szZipFile$, ByVal hParentWnd% ) As Integer    'Recreate the Zip file
  74. Declare Function ZipSetComment     Lib "ZDLL12A.dll"( ByVal szZipFile$, ByVal szComment$, 
  75.                            ByVal hParentWnd% ) As Integer            'Set the Zip Comment
  76.                   
  77.  
  78. '/* Helpers */
  79. Declare Function ZipSetLanguage Lib "ZDLL12A.dll"( ByVal cZipLanguage% ) As Integer            'Set the Language
  80. Declare Function ZipGetReplaceFlag Lib "ZDLL12A.dll"( ) As Integer                     'Return the current overwrite mode
  81.  
  82.  
  83.  
  84. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  85. //
  86. //        UnZip functions
  87. //
  88. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  89.  
  90.  
  91. '/* Initialisation function */
  92. Declare Sub      UnzipInit Lib "UZDLL12.dll"( ByVal szYourName$, ByVal szPassword$ )    'required, if you are not a registered user szYourName = "TEST"
  93.  
  94.  
  95. '/* Interface constants --- Already defined*/
  96. 'Global Const LANGUAGE_FRENCH        =0    ' french language will be used in the replace dialog box
  97. 'Global Const LANGUAGE_ENGLISH        =1    ' English language will be used in the replace dialog box ( default )
  98.  
  99.  
  100. '/* Interface setting functions */
  101. Declare Function UnzipSetMsgBoxTitle Lib "UZDLL12.dll"( ByVal szNewTitle$ ) As Integer    'Set the replace dialog box title ( default = "Replace...");
  102. Declare Sub      UnzipSetLanguage Lib "UZDLL12.dll"( ByVal iLanguage% )            'Set the language for the replace dialog box
  103. Declare Function UnzipSetReceivingWindow Lib "UZDLL12.dll"( ByVal hWnd% ) As Integer    'Set the window for notification messages
  104. Declare Sub      UnzipSetBackgroundMode Lib "UZDLL12.dll"( ByVal bBackGroundMode% )    'if TRUE, activate the multitask mode ( default )
  105.  
  106.  
  107. '/* Zip method constants */
  108. Global Const ZMETHOD_STORED        =0
  109. Global Const ZMETHOD_SHRUNK        =1
  110. Global Const ZMETHOD_REDUCE1        =2
  111. Global Const ZMETHOD_REDUCE2        =3
  112. Global Const ZMETHOD_REDUCE3        =4
  113. Global Const ZMETHOD_REDUCE4        =5
  114. Global Const ZMETHOD_IMPLODE        =6
  115. Global Const ZMETHOD_TOKEN        =7
  116. Global Const ZMETHOD_DEFLATE        =8
  117. Global Const ZMETHOD_UNKNOWN        =9
  118. Global Const ZMETHOD_ERROR        =10
  119.  
  120.  
  121. '/* Information functions ( Zip ) */
  122. Declare Function CountFileInZip     Lib "UZDLL12.dll"( ByVal szFileName$ ) As Integer            'Return number of files in this Zip File
  123. Declare Function GetFileNameFromZIP     Lib "UZDLL12.dll"( ByVal szFileName$, ByVal iFileNumber% ) As String    'Return the name of the iFileNumber file in this Zip File
  124. Declare Function GetZFileOriginalSize     Lib "UZDLL12.dll"( ByVal szZIPFileName$, ByVal szFileName$ ) As Long    'Return the not compressed size of szFileName in octets.
  125. Declare Function GetZFileCompressedSize Lib "UZDLL12.dll"( ByVal szZIPFileName$, ByVal szFileName$ ) As Long    'Return the compressed size of szFileName in octets.
  126. Declare Function GetZFileDate         Lib "UZDLL12.dll"( ByVal szZIPFileName$, ByVal szFileName$ ) As String    'Return the date of a file in a Zip
  127. Declare Function GetZFileTime         Lib "UZDLL12.dll"( ByVal szZIPFileName$, ByVal szFileName$ ) As String    'Return the time of a file in a Zip
  128. Declare Function GetZCompressMethod     Lib "UZDLL12.dll"( ByVal szZipFileName$, ByVal szFileName$ ) As Integer    'Return the Zip method for a file ( ZMETHOD_* )
  129. Declare Function IsThisFileAZipFile     Lib "UZDLL12.dll"( ByVal szFileName$ ) As Integer            'Return TRUE if this file seems to be a zip file
  130. Declare Function IsFileUnzipable     Lib "UZDLL12.dll"( ByVal szFileName$ ) As Integer            'Return TRUE if this file name can be reproduce under DOS
  131. Declare Function GetZipCommentLength     Lib "UZDLL12.dll"( ByVal szFileName$ ) As Integer            'Return the size of the zip file comment in octets
  132. Declare Function GetZipComment         Lib "UZDLL12.dll"( ByVal szFileName$, szBuffer$ ) As Integer        'Put the zip comment in buffer
  133.  
  134.  
  135. '/* Information functions ( General ) */
  136. Declare Function bDoesFileExist     Lib "UZDLL12.dll"( ByVal szFileName$ ) As Integer            'True if this file exists
  137. Declare Function GetShortFileName     Lib "UZDLL12.dll"( ByVal szFileName$ ) As String            'Return filename without any path
  138. Declare Function GetPathFromFileName     Lib "UZDLL12.dll"( ByVal szFileName$ ) As String            'Return the path without the file name
  139. Declare Function IsFileNameInFilter     Lib "UZDLL12.dll"( ByVal szFileName$, ByVal szMask$ ) As Integer    'Return TRUE if filename is in specified filter
  140.  
  141.  
  142. '/* Extraction function result constants */
  143. Global Const ZEXTRACT_OK        =0
  144. Global Const ZEXTRACT_INTERNALERROR    =1
  145. Global Const ZEXTRACT_FILENOTFOUND    =2
  146. Global Const ZEXTRACT_CORRUPTED        =3
  147. Global Const ZEXTRACT_EMPTY        =4
  148. Global Const ZEXTRACT_ERRORINZIPFILE    =5
  149. Global Const ZEXTRACT_NOMEM        =6
  150. Global Const ZEXTRACT_DISKFULL        =8
  151. Global Const ZEXTRACT_WARNING        =10
  152.  
  153.  
  154. '/* Helper constants */
  155. Global Const OVERWRITE_FALSE        =0
  156. Global Const OVERWRITE_TRUE        =1
  157. Global Const OVERWRITE_QUERY        =2
  158. Global Const CREATEDIR_FALSE        =0
  159. Global Const CREATEDIR_TRUE        =1
  160.  
  161.  
  162. '/* Extraction functions */                                        
  163. Declare Function ExtractZipFiles     Lib "UZDLL12.dll"( ByVal szFileName$, ByVal szMask$, ByVal szDestDir$, 
  164.                                ByVal bOverwrite%, ByVal bCreateDir% ) As Integer
  165. Declare Function GetQueryFlag         Lib "UZDLL12.dll"( ) As Integer                        'Return the overwrite mode the user asked for
  166.  
  167.  
  168. '/* Notification messages for UNZIP and VIEW*/
  169. 'Global Const ZN_OPENFILE    =WM_USER + 38    ' Open a file, WP = TRUE if Ok, LP = filename
  170. 'Global Const ZN_EXPANDING    =WM_USER + 39    ' Unzipping a file, WP = file current rate, LP = filename
  171. 'Global Const ZN_CLOSEFILE    =WM_USER + 40    ' Close a file, WP = TRUE if Ok, LP = filename
  172.  
  173.  
  174. '/* View function */
  175. Declare Function ViewFileFromZip     Lib "UZDLL12.dll"( ByVal szZipFile$, ByVal szMask$, 
  176.                                ByVal bTextOnly% ) As Integer            'View one or several files in a Zip
  177.                                
  178.  
  179. '/* ---------------------------------------- End of file ------------------------------------------*/
  180.             
  181.